﻿/****************************** Module Header ******************************\
 * Module Name:  ExMethodForPanel.cs
 * Module Version:  1.0.0 (2012-8-29)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to extension Form instance's method.  It supplies 
 * public static extension methods to load data or get othor control.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Windows.Forms;
using System.Reflection;

namespace UCF.Core.Forms
{
    public static class ExMethodForPanel
    {
        public static void ShowForm<T>(this Panel p, Func<T> act = null) where T : Form,new()
        {
            T frm = act == null ? new T() : act();
            frm.TopLevel = false;
            frm.Dock = DockStyle.Fill;
            p.Controls.Clear();
            p.Controls.Add(frm);
            frm.Show();
        }
    }
}
